for s in self.overrides.iter() {
let src = self.sources.get_mut(s).unwrap();
let dep = Dependency::new_override(dep.name(), s);
- ret.extend(try!(src.query(&dep)).into_iter().filter(|s| {
- seen.insert(s.name().to_string())
- }));
+ let mut results = try!(src.query(&dep));
+ if results.len() > 0 {
+ return Ok(Some(results.remove(0)))
+ }
}
- Ok(ret)
+ Ok(None)
}
- // This function is used to transform a summary to another locked summary if
- // possible. This is where the concept of a lockfile comes into play.
- //
- // If a summary points at a package id which was previously locked, then we
- // override the summary's id itself, as well as all dependencies, to be
- // rewritten to the locked versions. This will transform the summary's
- // source to a precise source (listed in the locked version) as well as
- // transforming all of the dependencies from range requirements on imprecise
- // sources to exact requirements on precise sources.
- //
- // If a summary does not point at a package id which was previously locked,
- // we still want to avoid updating as many dependencies as possible to keep
- // the graph stable. In this case we map all of the summary's dependencies
- // to be rewritten to a locked version wherever possible. If we're unable to
- // map a dependency though, we just pass it on through.
- fn lock(&self, summary: Summary) -> Summary {
+ /// This function is used to transform a summary to another locked summary
+ /// if possible. This is where the concept of a lockfile comes into play.
+ ///
+ /// If a summary points at a package id which was previously locked, then we
+ /// override the summary's id itself, as well as all dependencies, to be
+ /// rewritten to the locked versions. This will transform the summary's
+ /// source to a precise source (listed in the locked version) as well as
+ /// transforming all of the dependencies from range requirements on
+ /// imprecise sources to exact requirements on precise sources.
+ ///
+ /// If a summary does not point at a package id which was previously locked,
+ /// or if any dependencies were added and don't have a previously listed
+ /// version, we still want to avoid updating as many dependencies as
+ /// possible to keep the graph stable. In this case we map all of the
+ /// summary's dependencies to be rewritten to a locked version wherever
+ /// possible. If we're unable to map a dependency though, we just pass it on
+ /// through.
+ pub fn lock(&self, summary: Summary) -> Summary {
let pair = self.locked.get(summary.source_id()).and_then(|map| {
map.get(summary.name())
}).and_then(|vec| {